package com.objectcarpentry.kaylee.ui.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

import com.objectcarpentry.kaylee.IPlaylist;
import com.objectcarpentry.kaylee.ui.util.DirectionParameterValues;

public class NavigatePlaylistHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		
		String direction = event.getParameter("direction");
		Object o = event.getCommand().getState("playlist").getValue();
		if (o != null){
			IPlaylist playlist = (IPlaylist) o;
			if (direction.equals(DirectionParameterValues.NEXT)){
				playlist.next();
			} else if (direction.equals(DirectionParameterValues.PREVIOUS)){
				playlist.previous();
			} 
		}
		return null;
	}

}
